<template>
    <div class="custom-service-main">
      <div class="dialogueName-box">
        {{ dialogueName }}
      </div>
      
      <div class="main">
        <div v-for="(item, index) in msg" :key="index" class="dialogue" 
          :class="{'dialogue-rigth': item.type === 'R', 'dialogue-left': item.type === 'L'}">
            <div>
              {{ item.content }}
            </div>
        </div>
      </div>

      <div class="dialogueInput-height" v-if="dialogueName !== ''">
        <textarea class="textarea" placeholder="请输入需要发送的信息..." v-model="content"></textarea>
        <button class="dialogue-send-btn" @click="send">发送</button>
      </div>
    </div>
</template>
 
<script>
export default {
  name: 'custom-service-main',
  props: ['dialogueName', 'msg'],
  data() {
      return {
        content: ''
      }
  },
  methods: {
    send() {
      this.$emit('send', this.content, () => {
        this.content = ''
      })
    }
  }
}
</script>
 
<style scoped>
.custom-service-main{
    --dialogueName-box-height: 50px;
    --dialogueInput-height: 200px;
    width: calc(100% - var(--onLine-list-width) - var(--menu-width));
    padding: 20px;
}

.dialogueName-box{
  height: var(--dialogueName-box-height);
  box-sizing: border-box;
  padding: 10px;
  border-bottom: 1px solid #dedede;
}

.main{
  height: calc(100% - var(--dialogueName-box-height) - var(--dialogueInput-height));
  padding: 30px;
  box-sizing: border-box;
  overflow-y:auto;

}

.dialogueInput-height{
  height: var(--dialogueInput-height);
  border-top: 1px solid #dedede;
  box-sizing: border-box;
  padding: 10px;
}

.textarea{
  width: 100%;
  resize:none;
  border: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1px;
  word-spacing: 1px;
  outline: none;
  height: 130px;
  padding: 10px;
}

.dialogue-send-btn{
  height: 30px;
  box-sizing: border-box;
  padding: 2px 10px 2px 15px;
  border: none;
  letter-spacing: 5px;
  cursor: pointer;
}

.dialogue-send-btn:hover{
  background-color: #dedede;
}

.dialogue{
  width: 100%;
  box-sizing: border-box;
  min-height: 20px;
  line-height: 20px;
  position: relative;
  margin: 10px 0;
  overflow-wrap: break-word;
  display: flex;
}

.dialogue div{
  padding: 5px 8px;
}

.dialogue-rigth div{
  background-color: #dedede;
}

.dialogue-rigth{
  justify-content: flex-end;
}

.dialogue-rigth::after{
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  background-color: #dedede;
  transform: rotate(45deg);
  right: -3px;
  top: 30%;
  z-index: -1;
}

.dialogue-left{
  justify-content: flex-start;
}

.dialogue-left div{
  background-color: tomato;
  color: #fff;
}

.dialogue-left::after{
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  background-color: tomato;
  transform: rotate(45deg);
  left: -3px ;
  top: 30%;
  z-index: -1;
}

</style>